<template>
	<view class="conten">
		<topbar :top="top" @addmessage="addmasg"></topbar>
		<view class="txt-list" v-if="heads=='营业时间'">
			<view class="time-list" @click="show = true">
				<text>开始时间</text>
				<view class="times">
					<text>{{startime}}</text>
					<u-icon name="arrow-right"  size="28" ></u-icon>
				</view>
			</view>
			<view class="time-list" @click="shows = true">
				<text>结束时间</text>
				<view class="times">
					<text>{{tagtime}}</text>
					<u-icon name="arrow-right"  size="28"></u-icon>
				</view>
			</view>
			<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
			<u-select v-model="shows" :list="list" @confirm="confirms"></u-select>
		</view>
		<view class="txt-list" v-else>
			<text class="txt-head">{{heads}}</text>
			<view class="tarea">
				<u-input class="tarea_input" v-model="value"  :clearable="false" type="text" :placeholder="placeholder" :trim="true" />
			</view>
		</view>
		
	</view>
</template>

<script>
	import topbar from "@/components/topnav/topnav.vue"
	export default {
		components: {
			topbar
		},
		data() {
			return {
				form:[],
				shows:false,
				show:false,//下拉选择
				list:[
					{value:"1:00",label:"1:00"},
					{value:"2:00",label:"02:00"},{value:"3:00",label:"03:00"},{value:"4:00",label:"04:00"},{value:"5:00",label:"05:00"},
					{value:"6:00",label:"6:00"},{value:"7:00",label:"7:00"},{value:"8:00",label:"8:00"},{value:"9:00",label:"9:00"},
					{value:"10:00",label:"10:00"},{value:"11:00",label:"11:00"},{value:"12:00",label:"12:00"},{value:"13:00",label:"13:00"},
					{value:"14:00",label:"14:00"},{value:"15:00",label:"15:00"},{value:"16:00",label:"16:00"},{value:"17:00",label:"17:00"},
					{value:"18:00",label:"18:00"},{value:"19:00",label:"19:00"},{value:"20:00",label:"20:00"},{value:"21:00",label:"21:00"},
					{value:"22:00",label:"22:00"},{value:"23:00",label:"23:00"},{value:"24:00",label:"24:00"},
				],
				heads:"",
				value: '',
				placeholder:"请输入",
				startime:"",//开始时间
				tagtime:"",//结束时间
				top: {
					titlesize: 60,
					title: '素材预览',
					center: false,
					slotRight: true,
					backText: '',
					backIconName: 'nav-back',
					right: false,
					showAction: false,
					rightSlot: false,
					useSlot: false,
					background: {
						background: '#fff'
					},
					isBack: true,
					search: false,
					custom: false,
					isFixed: true,
					keyword: '',
					isicon:true,
					icon:"checkbox-mark",
					istext:true
				},
			}
		},
		onLoad(options) {
			this.form = uni.getStorageSync('addmerchant');
			if(this.form){
				this.top.title=options.id
				this.heads=options.id
				this.placeholder="请输入" + options.id
			}
		},
		onShow() {
			
		},
		methods:{
			confirm(e){
				console.log(e)
				this.startime=e[0].value
				let num = this.form.findIndex(el=>{
					return el.name==this.top.title
				})
				this.form[num].starttime = this.startime
			},
			confirms(e){
				console.log(e)
				this.tagtime=e[0].value
				let num = this.form.findIndex(el=>{
					return el.name==this.top.title
				})
				this.form[num].endtime = this.tagtime
			},
			// 保存信息
			addmasg(e){
				console.log(e)
				let num = this.form.findIndex(el=>{
					return el.name==this.top.title
				})
				console.log(this.form,"11111")
				console.log(num)
				this.form[num].pris = this.value
				uni.setStorageSync('addmerchant', this.form);
				uni.navigateBack({
				    delta: 1
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.conten{
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
		.txt-list{
			width: 690rpx;
			margin: 0 auto;
			.txt-head{
				font-size: 30rpx;
				line-height: 42rpx;
				color: #666666;
			}
			
		}
		.tarea{
			margin-top: -86rpx;
			width: 400rpx;
			margin-left: 160rpx;
			z-index: 99;
			// background-color: skyblue;
			padding: 30rpx;
			.txt-num{
				margin-right: 10rpx;
				text{
					text-align: right;
					color: #666666;
				}
			}
			.tarea_input{
				background-color: #fff;
			}
		}
	}
	.time-list{
		display: flex;
		justify-content: space-between;
		padding: 27rpx 0;
		border-bottom: 1px solid #EEEEEE;
	}
	.u-input{
		background-color: #F8F8F8;
	}
</style>
